package com.example.microservicediscoveryeureka.service;

import com.example.microservicecommon.User;
import com.example.microservicediscoveryeureka.configuration.RestTemplateConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(name = "microservice-provider-user",configuration = RestTemplateConfiguration.class,fallback = Fallback.class)
public interface UserService {

    @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)

    User findById(@PathVariable(name = "id") String id);

}
@Component
class Fallback implements UserService{

    @Override
    public User findById(String id) {
        return new User("Feign回退的用户","222");
    }
}
